import { set } from '@/utils/vuex'
import Cookies from 'js-cookie'
import { getLanguage } from '@/locales/index'

export default {
  namespaced: true,

  state: {
    drawer: null,
    language: getLanguage(),
  },
  mutations: {
    setDrawer: set('drawer'),
    SET_LANGUAGE: (state, language) => {
      state.language = language
      Cookies.set('language', language)
    },
  },
  actions: {
    setLanguage({ commit }, language) {
      commit('SET_LANGUAGE', language)
    },
  }
}
